home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 12 / BBS in a box XII-1.iso / Files / Unstuffers / Other Compression / MacGzip 0.21-src-c.sit / macgzip_021-src / macos / think / MacErrors.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-08  |  1.5 KB  |  81 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Copyright (C) 1993  SPDsoft
  3.  * 
  4.  */
  5.  
  6. #include <string.h>
  7. #include <errno.h>
  8.  
  9. #define Alert            151
  10. #define Warning            150
  11. #define    ErrResType        'Errs'
  12.  
  13. char _strerr[256];
  14.  
  15. /************************************************************************************/
  16.  
  17. void  Calert( char* theMsg )
  18. {    
  19.     CtoPstr(theMsg);
  20.     ParamText(theMsg,"\p","\p","\p");
  21.     PtoCstr(theMsg);
  22.     StopAlert(Alert,NULL);
  23. }
  24.  
  25. int  Cask( char* theMsg )
  26. {
  27.     CtoPstr(theMsg);
  28.     ParamText(theMsg,"\p","\p","\p");
  29.     return( CautionAlert(Warning,NULL) );
  30. }
  31.  
  32. void    PError( char *s )
  33. {
  34.     Str255 s2,s1;
  35.     Handle myHandle;
  36.     
  37.     sprintf((char*)_strerr,"%s: %s", s, strerror(errno));
  38.     CtoPstr((char*)_strerr);
  39.     
  40.     if ( errno != 0 )
  41.     {
  42.         if((myHandle=GetResource('Errs',errno))==nil)
  43.         {
  44.             NumToString( (long) errno, s2 );
  45.             ParamText(_strerr,"\p",s2,"\p???");
  46.         }    
  47.         else
  48.             ParamText(_strerr,"\p",*myHandle,(*myHandle)+**myHandle+1);
  49.     }
  50.     else ParamText(_strerr,"\p","\p","\p");
  51.  
  52.     StopAlert(Alert,NULL);
  53. }
  54.  
  55. /************************************************************************************/
  56.  
  57.  
  58. void  theAlert( int ErrorInd,int ErrorType, OSErr theOSErr, Boolean exiting)
  59. {
  60.     Str255 s2,s1;
  61.     Handle myHandle;
  62.     
  63.     if (ErrorType!=0) GetIndString( s1, ErrorType, ErrorInd);
  64.     else *s1=0x00;
  65.     
  66.     if ( theOSErr != 0 )
  67.     {
  68.         if((myHandle=GetResource(ErrResType,theOSErr))==nil)
  69.         {
  70.             NumToString( (long) theOSErr, s2 );
  71.             ParamText(s1,"\p",s2,"\p???");
  72.         }    
  73.         else
  74.             ParamText(s1,"\p",*myHandle,(*myHandle)+**myHandle+1);
  75.     }
  76.     else ParamText(s1,"\p","\p","\p");
  77.     StopAlert(Alert,NULL);
  78.     if ( exiting ) ExitToShell();
  79. }
  80.  
  81.